package tr.mesir.domain;

import javax.persistence.Entity;

import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;
import org.jboss.envers.Versioned;

/**
 * With the @Indexed annotation, Contact is declared as indexable.
 * 
 * Inside the class, you can see the hibernate validator annotations that are used
 * to express he domain constraints. Some of the validators, 
 * @NotEmpty - It checks for the non emptyness of the element.
 * @Length -  It checks for the length restriction of the element. 
 *    		  In this example it checks for a field of length between 4 and 40.
 * @Email - It checks for the element if it's a well-formed email address or not.
 * 
 * @author mertcaliskan
 */
@Entity
@Indexed 
@Versioned
public class Contact extends BaseObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8135480521774266176L;

	/**
	 * You can also specify your custom messages for the validators as in @NotEmpty
	 */
	@Field
	@NotEmpty(message="Name should not be empty")
	@Length(min=4, max=40)
	private String name;
	
	@Field
	@NotEmpty(message="Email should not be empty")
	@Email
	private String email;

	private String phone;
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
	}